const Chain = require('./chain');

// 异步职责链

const fn1 = new Chain(() => {
    console.log(1);
    return 'nextSuccessor';
});

const fn2 = new Chain(() => {
    console.log(2);
    setTimeout(() => {
        fn2.next();
    }, 1000);
});

const fn3 = new Chain(() => {
    console.log(3);
});

fn1.setNextSuccessor(fn2).setNextSuccessor(fn3);
fn1.passRequest();
